package com.example.academic_affairs_system.utils;

import java.security.GeneralSecurityException;

/**
 * 密码加密
 *
 * @author gzkemays
 * @since 2021/12/21 16:11
 */
public class PasswordSecurity {
  protected static final String SECURITY = "u9Aj913MtP7J2Rq@Yzj_forum-gzkemays";

  public static String generatedPassword(String pwd) {
    try {
      return AesUtils.encrypt(pwd, SECURITY);
    } catch (GeneralSecurityException e) {
      e.printStackTrace();
      return null;
    }
  }

  public static String parsePassword(String pwd) {
    try {
      return AesUtils.decrypt(pwd, SECURITY);
    } catch (GeneralSecurityException e) {
      e.printStackTrace();
      return null;
    }
  }

  private static String getIndex(String str) {
    byte[] bytes = str.getBytes();
    StringBuilder result = new StringBuilder();
    for (byte b : bytes) {
      result.append(b);
    }
    return result.toString();
  }

  public static void main(String[] args) {
    System.out.println(generatedPassword("a96548854"));
  }
}
